package com.itheima.controller;

import com.itheima.manager.UmsAdminManager;
import com.itheima.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/admin")
public class UmsAdminController {

    @Autowired
    UmsAdminManager umsAdminManager;

    //登陆
    @PostMapping("/login")
    public R login(@RequestBody Map<String ,String> map){
        return umsAdminManager.login(map);
    }

    //获取当前登录用户信息
    @GetMapping("/info")
    public R getAdminInfo(){
        return umsAdminManager.getAdminInfo();
    }

    //登出
    @PostMapping("/logout")
    public R logout(@RequestHeader("Authorization")String token){
        return umsAdminManager.logout(token);
    }

    //刷新token
    @GetMapping("/refreshToken")
    public R refreshToken(@RequestHeader("Authorization")String token){
        return umsAdminManager.refreshToken(token);
    }
}
